﻿package Chapter06;
import java.util.ArrayList;

public class ArrayListExample {
	void runArrayList() {
		// 1.
		ArrayList<String> myList = new ArrayList<String>();
		// 2.
		String a = new String("whoohoo");
		myList.add(a);
		// 3.
		String b = new String("Frog");
		myList.add(b);
		// 4.
		int theSize = myList.size();
		// 5.
		Object o = myList.get(1);
		// 6.
		myList.remove(1);
		// 7.
		boolean isIn = myList.contains(b);
	}
	
	void runArray() {
		// 1.
		String[] myList = new String[2];
		// 2.
		String a = new String("whoohoo");
		myList[0] = a;
		// 3.
		String b = new String("Frog");
		myList[1] = b;
		// 4.
		int theSize = myList.length;
		// 5.
		String o = myList[1];
		// 6.
		//myList.remove(1);
		myList[1] = null;
		// 7.
		//boolean isIn = myList.contains(b);
		boolean isIn = false;
		for (String s : myList) {
			if (b.equals(s)) {
				isIn = true;
				break;
			}
		}
	}
}
